<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>支付方式编辑</title>
<link href="<%=basePath%>skin/css/validform/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=basePath%>skin/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/validform/Validform_v5.3.2_min.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/editor/kindeditor.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/common.js"></script>
<script language="javascript">
	 $().ready(function(){
		//验证
		var validform = $("#form1").Validform({
			btnSubmit:"#save",
			tiptype:3
		});
		validform.addRule([
			{
			    ele:"#name",
			    datatype:"*",
			    nullmsg:"请输入名称！"
			},
			{
			    ele:"#timeout",
			    datatype:"n",
			    nullmsg:"请输入超时时间！"
			},
			{
			    ele:"#orders",
			    datatype:"n",
			    nullmsg:"请输入排序！"
			}
		]);
		 <c:forEach items="${paymentMethod.shippingMethods }" var="pshippingMethod">
		 	var psmId = ${pshippingMethod.id};
		 	$("input[name='shippingMethodId']").each(function(){
		 		var $this = $(this);
		 		if($this.val() == psmId) {
		 			$this.attr("checked",true);
		 		}
		 	});
		 </c:forEach>
	 });
</script>
</head>

<body>
	<form id="form1" name="form1" method="post" action="<%=basePath%>admin/paymentMethod/update.shtml">
	<input type="hidden" name="id" value="${paymentMethod.id}" />
		<table width="98%" class="input tabContent">
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">名称：</td>
				<td class="tdLeft"><input id="name" name="name"
					size="30" class="input" value="${paymentMethod.name }"/></td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">方式：</td>
				<td class="tdLeft">
					<select name="method">
						<option value="0" <c:if test="${not empty paymentMethod.method && paymentMethod.method == 0 }">selected</c:if>>网上支付</option>
						<option value="1" <c:if test="${not empty paymentMethod.method && paymentMethod.method == 1 }">selected</c:if>>线下支付</option>
					</select>
				</td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">超时时间：</td>
				<td class="tdLeft"><input id="timeout" name="timeout"
					size="30" class="input" value="${paymentMethod.timeout }"/></td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">支持配送方式：</td>
				<td class="tdLeft">
					<c:forEach items="${shippingMethods }" var="shippingMethod">
						<input type="checkbox" name="shippingMethodId" value="${shippingMethod.id }"/>${shippingMethod.name }
					</c:forEach>
				</td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">介绍：</td>
				<td class="tdLeft"><input id="description" name="description"
					size="30" class="input" value="${paymentMethod.description }"/></td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">排序：</td>
				<td class="tdLeft"><input id="orders" name="orders"
					size="30" class="input" value="${paymentMethod.orders }"/></td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">内容：</td>
				<td class="tdLeft">
					<textarea id="editor" name="content" class="editor" style="width: 100%;">${paymentMethod.content }</textarea>
				</td>
			</tr>
		</table>
		<table width="98%">
			<tr bgcolor="#EEF4EA">
				<td height="36" colspan="10">
					<input type="button" value="确定" class="button" id="save" />
					<input type="button" value="返回" class="button" onclick="location.href='<%=basePath%>admin/paymentMethod/list.shtml'" />
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
